package cn.janescott.inner.space.lib.dto;

import cn.janescott.inner.space.lib.constant.CommonEnums;

/**
 * @author scott
 * @date 2018/7/31
 */
public class Result<T> {

    private int code;

    private String status;

    private String message;

    private T data;

    public int getCode() {
        return code;
    }

    public Result<T> setCode(int code) {
        this.code = code;
        return this;
    }

    public String getStatus() {
        return status;
    }

    public Result<T> setStatus(String status) {
        this.status = status;
        return this;
    }

    public String getMessage() {
        return message;
    }

    public Result<T> setMessage(String message) {
        this.message = message;
        return this;
    }

    public T getData() {
        return data;
    }

    public Result<T> setData(T data) {
        this.data = data;
        return this;
    }

    public Result() {

    }

    public Result(T data) {
        this(CommonEnums.RESULT_CODE.C_200.getCode(), null, null, data);
    }

    public Result(int code, String status, String message, T data) {
        this.code = code;
        this.status = status;
        this.message = message;
        this.data = data;
    }

    public static <T> Result<T> newInstance() {
        return new Result<>();
    }

    public static <T> Result<T> success(T data) {
        return new Result<>(data);
    }

}
